# -*- coding: utf-8 -*-
import unittest
from structures.list import List


class ListTest(unittest.TestCase):

    def test_create_list_check_empty(self):
        list = List()

        self.assertTrue(list.empty())

    def test_create_list_add_element_check_emtpy(self):
        list = List()

        list.add(1)

        self.assertFalse(list.empty())

    def test_add_two_items_pop_them_check_values_check_empty(self):
        list = List()

        list.add(1)
        list.add(2)

        value = list.pop()
        self.assertEqual(2, value)

        value = list.pop()
        self.assertEqual(1, value)

        self.assertTrue(list.empty())

    def test_add_items_first_pop_them_check_values_check_empty(self):
        list = List()

        list.add_first(1)
        list.add_first(2)

        value = list.pop()
        self.assertEqual(1, value)

        value = list.pop()
        self.assertEqual(2, value)

        self.assertTrue(list.empty())

    def test_add_items_use_iterator(self):
        list = List()

        list.add_first(1)
        list.add_first(2)
        list.add_first(3)

        count = 0
        for item in list:
            count += 1

        self.assertEqual(3, count)
